﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace movingControl
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        Button[] bs;
        private void x_Click(object sender, RoutedEventArgs e)
        {

            for (int i = 0; i < 3; i++)
            {
                Button btn = new Button() { Content = i.ToString() };
                wp.Children.Add(btn);
            }
            bs = wp.Children.Cast<Button>().ToArray();
        }
        void resetWp()
        {
            wp.Children.Clear();
            foreach (var btn in bs)
            {
                wp.Children.Add(btn);
            }
        }

        private void y_Click(object sender, RoutedEventArgs e)
        {
            var t = bs[1];
            bs[1] = bs[2];
            bs[2] = t;

            resetWp();
        }
    }
}
